import React,{useState} from 'react';
import {Text, View, Button, StyleSheet} from 'react-native';

export default function ( props ): React.JSX.Element {

  const data = JSON.stringify(props?.route?.params.data || {});
  const [params, setParams] = useState<any>(data);
  // 可以通过 route.params 获取传递的参数
  //setParams(props?.route?.params.data || {});

  return (
    <View style={styles.container}>
      <Text>Test2 Screen</Text>
      <View style={{marginTop: 20}}>
        <Text style={styles.text}>Received Params: {params}</Text>
      </View>
      <View style={{marginTop: 20}}>
        <Button title="Go back" onPress={() => props.navigation.goBack()} />
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  text: {fontSize: 20, fontWeight: 'bold'},
});
